package fitnesshub.controller.member;

import fitnesshub.pojo.dto.CoachPageQueryDTO;
import fitnesshub.pojo.entity.Coach;
import fitnesshub.result.PageResult;
import fitnesshub.result.Result;
import fitnesshub.service.CoachService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 会员-教练
 */
@RestController
@RequestMapping("/member/coach")
@Slf4j
public class MemberCoachController {
    @Autowired
    private CoachService coachService;

    /**
     * 会员教练分页
     * @param coachPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> page(CoachPageQueryDTO coachPageQueryDTO) {
        log.info("会员教练分页查询，参数：{}", coachPageQueryDTO);
        PageResult pageResult = coachService.page(coachPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 根据id查询教练
     * @param coachId
     * @return
     */
    @GetMapping("/{coachId}")
    public Result<Coach> getById(@PathVariable Integer coachId) {
        log.info("根据id:{},查询教练", coachId);
        Coach coach = coachService.getById(coachId);
        return Result.success(coach);
    }
}
